package com.lanan.springboot.service;

import com.lanan.springboot.model.Topic;
import com.lanan.springboot.model.User;
import com.lanan.springboot.util.MyPage;

import java.util.List;
import java.util.Map;

/**
 * @desc ITopicService
 * @author lanan
 * @date 2022-04-15 17:36:19
 **/
public interface ITopicService {
    /**
     * @desc 搜索
     * @author lanan
     * @date 2022-04-15 17:36:30
     * @param pageNo
     * @param pageSize
     * @param keyword
     * @return com.lanan.springboot.util.MyPage<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    MyPage<Map<String, Object>> search(Integer pageNo, Integer pageSize, String keyword);

    /**
     * @desc 分页查询话题
     * @author lanan
     * @date 2022-04-15 17:36:36
     * @param pageNo
     * @param tab
     * @return com.lanan.springboot.util.MyPage<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    MyPage<Map<String, Object>> selectAll(Integer pageNo, String tab);

    /**
     * @desc 查询话题作者其它的话题
     * @author lanan
     * @date 2022-04-15 17:36:43
     * @param userId
     * @param topicId
     * @param limit
     * @return java.util.List<com.lanan.springboot.model.Topic>
     **/
    List<Topic> selectAuthorOtherTopic(Integer userId, Integer topicId, Integer limit);

    /**
     * @desc 查询用户的话题
     * @author lanan
     * @date 2022-04-15 17:36:49
     * @param userId
     * @param pageNo
     * @param pageSize
     * @return com.lanan.springboot.util.MyPage<java.util.Map<java.lang.String,java.lang.Object>>
     **/
    MyPage<Map<String, Object>> selectByUserId(Integer userId, Integer pageNo, Integer pageSize);

    /**
     * @desc 保存话题
     * @author lanan
     * @date 2022-04-15 17:36:55
     * @param title
     * @param content
     * @param tags
     * @param user
     * @return com.lanan.springboot.model.Topic
     **/
    Topic insert(String title, String content, String tags, User user);

    /**
     * @desc 根据id查询话题
     * @author lanan
     * @date 2022-04-15 17:37:00
     * @param id
     * @return com.lanan.springboot.model.Topic
     **/
    Topic selectById(Integer id);

    /**
     * @desc 根据title查询话题，防止重复话题
     * @author lanan
     * @date 2022-04-15 17:37:09
     * @param title
     * @return com.lanan.springboot.model.Topic
     **/
    Topic selectByTitle(String title);

    /**
     * @desc 处理话题的访问量
     * @author lanan
     * @date 2022-04-15 17:37:15
     * @param topic
     * @param ip
     * @return com.lanan.springboot.model.Topic
     **/
    Topic updateViewCount(Topic topic, String ip);

    /**
     * @desc 更新话题
     * @author lanan
     * @date 2022-04-15 17:37:23
     * @param topic
     * @param tags
     * @return void
     **/
    void update(Topic topic, String tags);

    /**
     * @desc 删除话题
     * @author lanan
     * @date 2022-04-15 17:37:29
     * @param topic
     * @return void
     **/
    void delete(Topic topic);

    /**
     * @desc 根据用户id删除帖子
     * @author lanan
     * @date 2022-04-15 17:37:36
     * @param userId
     * @return void
     **/
    void deleteByUserId(Integer userId);

    MyPage<Map<String, Object>> selectAllForAdmin(Integer pageNo, String startDate, String endDate, String username);

    /**
     * @desc 查询今天新增的话题数
     * @author lanan
     * @date 2022-04-15 17:37:44
     * @return int
     **/
    int countToday();

    int vote(Topic topic, User user);
}
